﻿using System;

namespace 抽象类
{
    //关键字：abstract
    //抽象方法必须没有方法体
    //无法创建抽象类对象
    //和虚方法 区别 抽象类没能力

    //如果子类继承父类 子类必须实现抽象父类的成员
    internal class Program
    {
        private static void Main(string[] args)
        {
            //狗狗会叫 猫咪也会叫
            //Animal a = new Animal();  会报错
            Animal dog = new Dog();
            dog.Bark();  //表现出来依然是父类
            Animal cat = new Cat();
            cat.Bark();

            Shape s = new Circular(1);
            Console.WriteLine($"面积为{s.GetArea()},周长为{s.GetPerimeter()},");
            Console.ReadKey();
        }
    }

    public abstract class Animal
    {
        public abstract void Bark();    //无方法体

        public abstract string Name
        {
            get; set;
        }
    }

    public class Dog : Animal
    {
        public override string Name { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

        public override void Bark()
        {
            Console.WriteLine("狗汪汪");
        }
    }

    public class Cat : Animal
    {
        public override string Name { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

        public override void Bark()
        {
            Console.WriteLine("猫喵喵");
        }
    }
}